#include"head.h"


//开始等待连接
 int start_listen( int socket_fd,const char * ip, const char * port)
{

    struct sockaddr_in sockaddr;
    sockaddr.sin_family=AF_INET;
    sockaddr.sin_port=htons(atoi(port));
    sockaddr.sin_addr.s_addr=inet_addr(ip);

    int ret;
int reuse=1;
  setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));

    ret = bind(socket_fd,(struct sockaddr*)&sockaddr,sizeof(sockaddr));
    ERROR_CHECK(ret,-1,"bind");

    ret = listen(socket_fd,10);
    ERROR_CHECK(ret,-1,"listen");
    printf("listen done\n");

    return 0;
}
